<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>标签专题图</title>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="../../dist/include-leaflet.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? document.location.protocol + "//" + document.location.host : "http://support.supermap.com.cn:8090";
    var map, themeService, themeLabel, themeParameters, themeLayer,
        url = host + "/iserver/services/map-world/rest/maps/World";
    map = L.map('map', {
        crs: L.CRS.EPSG4326,
        center: [0, 0],
        maxZoom: 18,
        zoom: 1
    });
    L.supermap.tiledMapLayer(url, {noWrap: true, transparent: true}).addTo(map);
    createTheme();

    function createTheme() {
        themeService = L.supermap.themeService(url);
        var style1 = new SuperMap.ServerTextStyle({
            fontHeight: 4,
            foreColor: new SuperMap.ServerColor(100, 20, 50),
            sizeFixed: true,
            bold: true

        });
        var style2 = new SuperMap.ServerTextStyle({
            fontHeight: 4,
            foreColor: new SuperMap.ServerColor(250, 0, 0),
            sizeFixed: true,
            bold: true
        });
        var style3 = new SuperMap.ServerTextStyle({
            fontHeight: 4,
            foreColor: new SuperMap.ServerColor(93, 95, 255),
            sizeFixed: true,
            bold: true
        });
        var themeLabelItem1 = new SuperMap.ThemeLabelItem({
            start: 0.0,
            end: 7800000,
            style: style1
        });
        var themeLabelItem2 = new SuperMap.ThemeLabelItem({
            start: 7800000,
            end: 15000000,
            style: style2
        });
        var themeLabelItem3 = new SuperMap.ThemeLabelItem({
            start: 15000000,
            end: 30000000,
            style: style3
        });
        var themeLabelItem4 = new SuperMap.ThemeLabelItem({
            start: 0.0,
            end: 55,
            style: style1
        });
        var themeLabelItem5 = new SuperMap.ThemeLabelItem({
            start: 55,
            end: 109,
            style: style2
        });
        var themeLabelItem6 = new SuperMap.ThemeLabelItem({
            start: 109,
            end: 300,
            style: style3
        });

        themeLabel = new SuperMap.ThemeLabel({
            matrixCells: [
                [new SuperMap.LabelThemeCell({
                    themeLabel: new SuperMap.ThemeLabel({
                        labelExpression: "CAP_POP",
                        rangeExpression: "CAP_POP",
                        numericPrecision: 0,
                        items: [themeLabelItem1, themeLabelItem2, themeLabelItem3]
                    })
                })],
                [new SuperMap.LabelThemeCell({
                    themeLabel: new SuperMap.ThemeLabel({
                        labelExpression: "CAPITAL",
                        rangeExpression: "SmID",
                        numericPrecision: 0,
                        items: [themeLabelItem4, themeLabelItem5, themeLabelItem6]
                    })
                })]
            ],
            background: new SuperMap.ThemeLabelBackground({
                backStyle: new SuperMap.ServerStyle({
                    fillForeColor: new SuperMap.ServerColor(179, 209, 193),
                    fillOpaqueRate: 60,
                    lineWidth: 0.1
                }),
                labelBackShape: "RECT"
            })
        });
        themeParameters = new SuperMap.ThemeParameters({
            themes: [themeLabel],
            datasetNames: ["Capitals"],
            dataSourceNames: ["World"]
        });
        themeService.getThemeInfo(themeParameters, function (serviceResult) {
            var result = serviceResult.result;
            if (result && result.newResourceID) {
                themeLayer = L.supermap.tiledMapLayer(url, {
                    noWrap: true,
                    cacheEnabled: false,
                    transparent: true,
                    layersID: result.newResourceID
                }).addTo(map);
            }
        });
    }
</script>
</body>
</html>